<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use  HasFactory, Notifiable;
    protected $table = 'user';
    protected $guarded = [];

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];


    /**
     * @param $uid
     * @return mixed
     * 查询用户指定余额
     */
    public static function findMoney($uid){
        return self::where('uid',$uid)->value('now_money');
    }

    /**
     * @param $uid
     * @param $money
     * @return mixed
     * 修改余额
     */
    public static function UpMoney($uid,$money){
         return self::where('uid',$uid)->update([
             'now_money' =>$money
         ]);
    }

    /**
     * @param $uid
     * 获取当前用户信息
     */
    public static function information($uid){
        return self::select('real_name','card_id','phone')->where('uid',$uid)->first()->toarray();
    }
    /**
     * @param $data
     * @return mixed
     * 修改团长佣金所得
     */
    public static function upGroupBossPrice($data){
        return self::where("uid",$data['uid'])->update(["brokerage_price"=>$data['brokerage_price']]);
    }

}
